<?php

include_once ('db_manage.php');

function getUploadPicArray($sql) {
    $array = array();
    $result = mysql_query($sql);
    $i = 0;
    if ($result != false) {
        $data = array();
        $i = 0;
        while (($row = mysql_fetch_array($result, MYSQL_ASSOC)) != false) {            
            $uploadPic = new UploadPic ();
            $uploadPic->setId($row['id']);
            $uploadPic->setFid($row['fid']);
            $uploadPic->setModule($row['module']);
            $uploadPic->setSrc($row['src']);
            $uploadPic->setSrc_smal($row['src_smal']);
            $uploadPic->setUserid($row['userid']);
            $uploadPic->setType($row['type']);
            $uploadPic->setArea($row['area']);
            $uploadPic->setDian($row['dian']);
            $uploadPic->setHot($row['hot']);
            $uploadPic->setScore($row['score']);
            $uploadPic->setDescription($row['description']);
            $uploadPic->setPostdate($row['postdate']);

            $array [$i] = $uploadPic;
            $i++;
        }
        mysql_free_result($result);        
    }

    return $array;
}

function getUploadPicByTravel($travlid) {
    $sql = "select * from pcd_upload_travel WHERE fid = " . $travlid;
    $array = getUploadPicArray($sql);
    return $array;
}

function getUploadPicByRoute($id) {
    $sql = "select * from pcd_upload_travel WHERE fid IN (SELECT travelid FROM pcd_travel_route WHERE routeid = " . $id . ")";
    $array = getUploadPicArray($sql);
    return $array;
}

class UploadPic {

    var $id;
    var $fid;
    var $module;
    var $src;
    var $src_smal;
    var $userid;
    var $type;
    var $area;
    var $dian;
    var $hot;
    var $score;
    var $description;
    var $postdate;

    /**
     * @return the $id
     */
    public function getId() {
        return $this->id;
    }

    /**
     * @return the $fid
     */
    public function getFid() {
        return $this->fid;
    }

    /**
     * @return the $module
     */
    public function getModule() {
        return $this->module;
    }

    /**
     * @return the $src
     */
    public function getSrc() {
        return $this->src;
    }

    /**
     * @return the $src_smal
     */
    public function getSrc_smal() {
        return $this->src_smal;
    }

    /**
     * @return the $userid
     */
    public function getUserid() {
        return $this->userid;
    }

    /**
     * @return the $type
     */
    public function getType() {
        return $this->type;
    }

    /**
     * @return the $area
     */
    public function getArea() {
        return $this->area;
    }

    /**
     * @return the $dian
     */
    public function getDian() {
        return $this->dian;
    }

    /**
     * @return the $hot
     */
    public function getHot() {
        return $this->hot;
    }

    /**
     * @return the $score
     */
    public function getScore() {
        return $this->score;
    }

    /**
     * @return the $description
     */
    public function getDescription() {
        return $this->description;
    }

    /**
     * @return the $postdate
     */
    public function getPostdate() {
        return $this->postdate;
    }

    /**
     * @param field_type $id
     */
    public function setId($id) {
        $this->id = $id;
    }

    /**
     * @param field_type $fid
     */
    public function setFid($fid) {
        $this->fid = $fid;
    }

    /**
     * @param field_type $module
     */
    public function setModule($module) {
        $this->module = $module;
    }

    /**
     * @param field_type $src
     */
    public function setSrc($src) {
        $this->src = $src;
    }

    /**
     * @param field_type $src_smal
     */
    public function setSrc_smal($src_smal) {
        $this->src_smal = $src_smal;
    }

    /**
     * @param field_type $userid
     */
    public function setUserid($userid) {
        $this->userid = $userid;
    }

    /**
     * @param field_type $type
     */
    public function setType($type) {
        $this->type = $type;
    }

    /**
     * @param field_type $area
     */
    public function setArea($area) {
        $this->area = $area;
    }

    /**
     * @param field_type $dian
     */
    public function setDian($dian) {
        $this->dian = $dian;
    }

    /**
     * @param field_type $hot
     */
    public function setHot($hot) {
        $this->hot = $hot;
    }

    /**
     * @param field_type $score
     */
    public function setScore($score) {
        $this->score = $score;
    }

    /**
     * @param field_type $description
     */
    public function setDescription($description) {
        $this->description = $description;
    }

    /**
     * @param field_type $postdate
     */
    public function setPostdate($postdate) {
        $this->postdate = $postdate;
    }

}

?>